﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BCService.MakeStaticPagingComponent.TagParseService
{
    public class TagParseService : ITagParseService
    {
        public TagParseService()
        {
        }
        public string Parse(Type type,string source, string methodName, string paramsValue)
        {
            while (paramsValue.IndexOf("\"") > -1)
            {
                paramsValue = paramsValue.Replace("\"", "");
            }
            switch (methodName)
            {
                case "format":
                    return this.Format(type,source, paramsValue);
                default:
                    return source;
            }
        }
        /// <summary>
        /// 格式化字符串
        /// </summary>
        /// <param name="type">对象结果类型</param>
        /// <param name="source">原始值</param>
        /// <param name="pattern">格式化规则模式</param>
        /// <returns></returns>
        private string Format(Type type, string source, string pattern)
        {
            Console.WriteLine(type.Name);
            switch (type.Name)
            {
                case "DateTime":
                    DateTime dateTime = DateTime.Parse(source);
                    return dateTime.ToString(pattern);
            }
            
            return source;
        }

        
    }
}
